package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.utility.util.StringUtil;

/**
 * 银联细化应答码操作
 *
 * @author yangfan
 * @version 1.0
 * @date 2021/5/17
 */
public enum CupsRspCodeEnum {
    /**
     * F39 应答码
     */
    F39_RSPCODE(F39_RspCodeEnum.class),
    /**
     * F57_AS_AR 附加应答信息
     */
    F57_AS_AR_RSPCODE(F57_AS_AR_RspCodeEnum.class);

    interface Type {

    }

    CupsRspCodeEnum.Type[] values;

    public Type[] getValues() {
        return values;
    }

    CupsRspCodeEnum(Class<? extends CupsRspCodeEnum.Type> kind) {
        this.values = kind.getEnumConstants();
    }

    /**
     * 获取银联应答码细化信息
     *
     * @param f39_RspCode       F39 应答码
     * @param f57_AS_AR_RspCode F57_AS_AR  附加应答信息
     * @return 银联细化应答信息
     */
    public static CupsRspCodeEnum.Type getResult(String f39_RspCode, String f57_AS_AR_RspCode) {
        if (StringUtil.isEmptyOrNull(f57_AS_AR_RspCode)) {
            return F39_RspCodeEnum.getResult(f39_RspCode);
        } else {
            return F57_AS_AR_RspCodeEnum.getResult(f39_RspCode, f57_AS_AR_RspCode);
        }
    }

    /**
     * 获取银联细化应答描述
     *
     * @param f39_RspCode       F39 应答码
     * @param f57_AS_AR_RspCode F57_AS_AR  附加应答信息
     * @return 银联细化应答描述
     */
    public static String getRspMsg(String f39_RspCode, String f57_AS_AR_RspCode) {
        if (StringUtil.isEmptyOrNull(f57_AS_AR_RspCode)) {
            return F39_RspCodeEnum.getRspMsg(f39_RspCode);
        } else {
            return F57_AS_AR_RspCodeEnum.getRspMsg(f39_RspCode, f57_AS_AR_RspCode);
        }
    }
}
